﻿//
// ToDoList v2.0
// Onat Yigit Mercan
// onatmercan [at] gmail [dot] com
//
using System;
using System.IO;
using System.Text;

namespace ToDoList
{
    public class FileHandler
    {
        private string directoryPath;
        private string fileName;
        private string filePath;

        public FileHandler(string directoryPath, string fileName)
        {
            this.directoryPath = directoryPath;
            this.fileName = fileName;

            SetFilePath();

            if (!File.Exists(filePath))
                File.Create(filePath).Close();
        }

        public string DirectoryPath
        {
            get { return this.directoryPath; }
            set { this.directoryPath = value; }
        }

        public string FileName
        { 
            get { return this.fileName; }
            set { this.fileName = value; }
        }

        public string FilePath
        {
            get { return this.filePath; }
        }

        public void SetFilePath()
        {
            filePath = Path.Combine(this.directoryPath, this.fileName);
        }

        public bool CheckFile()
        {
            return File.Exists(filePath);
        }

        public string ReadFile()
        {
            return File.ReadAllText(filePath).ToString();
        }

        public void WriteFile(string input)
        {
            File.WriteAllText(filePath, input);
        }

        public void MoveFile(string oldFilePath, string newFilePath)
        {
            File.Move(oldFilePath, newFilePath);
        }
    }
}
